package com.polaris.live.adapter

import android.view.View
import android.view.ViewGroup
import com.polaris.live.R
import com.polaris.live.databinding.AdapterMyBeansSeatBinding
import com.polaris.live.resp.back_resp.MyBeansSeatTabBean
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder

/**
 * MyBeansSeatAdapter
 *
 * @author Created by 半仙 on 2024/12/11/011 11:56
 */
class MyBeansSeatAdapter : BaseBannerAdapter<MyBeansSeatTabBean>() {

    override fun createViewHolder(
        parent: ViewGroup,
        itemView: View,
        viewType: Int,
    ): BaseViewHolder<MyBeansSeatTabBean> {
        return MyBeansSeatViewHolder(AdapterMyBeansSeatBinding.bind(itemView))
    }

    override fun bindData(
        holder: BaseViewHolder<MyBeansSeatTabBean>?,
        data: MyBeansSeatTabBean?,
        position: Int,
        pageSize: Int,
    ) {
        if (holder is MyBeansSeatViewHolder) {
            holder.binding.apply {
                tvContent1.text = data?.contentOne.toString()
                tvContent2.text = data?.contentTwo.toString()
                if (data?.contentThree != null) {
                    tvContent3.text = data.contentThree.toString()
                    tvContent3.visibility = View.VISIBLE
                } else {
                    tvContent3.visibility = View.GONE
                }
            }
        }
    }

    class MyBeansSeatViewHolder(val binding: AdapterMyBeansSeatBinding) :
        BaseViewHolder<MyBeansSeatTabBean>(binding.root)

    override fun getLayoutId(viewType: Int): Int {
        return R.layout.adapter_my_beans_seat
    }
}